﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.IO;
using System.Web;
using System.Threading.Tasks;
using System.Data;
using BartonExtension;
using ResponseObject;
using SQLWrapper;
using Model.App;
using Model.Images;
using Model.Weixin;
using Services.Common;
using Services.Group;

namespace iShangMai.Controllers
{
    public class GroupMessageController : ApiController
    {
        [HttpPost]
        public async Task<ZKResponse> CommentGroupMessage(ISMAddGroupMessageCommentRequest request)
        {
            ZKResponse response = new ZKResponse();
            var provider = (ISMGroupServiceProvider)ISMServiceStack.sharedInstance[ISMServiceStackKeys.GROUP];
            ISMServiceModel model = new ISMServiceModel()
            {
                operationIdentifier = ISMGroupServiceProvider.ADD_GROUP_MESSAGE_COMMENT,
                userinfo = request
            };
            var result = await provider.doProcess(model);
            response.isProcessSuccess = result.isOperationSuccess;
            response.errMsg = result.errorMsg;
            response.userinfo = result.dbReturningState;
            return response;
        }
        [HttpGet]
        public async Task<ZKResponse> GetComments(UInt64 group_message_id,int page,int pageSize,string token)
        {
            ZKResponse response = new ZKResponse();
            ISMGetGroupMessageCommentsRequest request = new ISMGetGroupMessageCommentsRequest()
            {
                group_message_id = group_message_id,
                page = page,
                pageSize = pageSize,
                token = token
            };
            var provider = (ISMGroupServiceProvider)ISMServiceStack.sharedInstance[ISMServiceStackKeys.GROUP];
            ISMServiceModel model = new ISMServiceModel()
            {
                operationIdentifier = ISMGroupServiceProvider.GET_GROUP_MESSAGE_COMMENTS,
                userinfo = request
            };
            var result = await provider.doProcess(model);
            response.isProcessSuccess = result.isOperationSuccess;
            response.errMsg = result.errorMsg;
            response.userinfo = result.dbReturningState;
            return response;
        }
    }
}
